import { post, get, put, del } from '../utils/request';

/**
 * 代理管理相关API
 */

// 获取代理列表
export const getAgentList = (params?: {
  page?: number;
  pageSize?: number;
  status?: string;
  level?: string;
  keyword?: string;
}) => {
  return get('/v1/agent/list', params);
};

// 获取代理详情
export const getAgentDetail = (id: string) => {
  return get(`/v1/agent/${id}`);
};

// 添加代理
export const addAgent = (data: {
  name: string;
  phone: string;
  level: string;
  commission: number;
  description?: string;
}) => {
  return post('/v1/agent', data);
};

// 更新代理
export const updateAgent = (id: string, data: {
  name?: string;
  phone?: string;
  level?: string;
  commission?: number;
  description?: string;
}) => {
  return put(`/v1/agent/${id}`, data);
};

// 删除代理
export const deleteAgent = (id: string) => {
  return del(`/v1/agent/${id}`);
};

// 代理状态管理
export const updateAgentStatus = (id: string, status: string) => {
  return put(`/v1/agent/${id}/status`, { status });
};

// 获取代理统计数据
export const getAgentStats = () => {
  return get('/v1/agent/stats');
};

// 获取代理佣金记录
export const getAgentCommission = (id: string, params?: {
  page?: number;
  pageSize?: number;
  startDate?: string;
  endDate?: string;
}) => {
  return get(`/v1/agent/${id}/commission`, params);
};
